package com.zhentao.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhentao.domain.SysPowerCabinet;
import com.zhentao.domain.dto.PageDto;
import com.zhentao.domain.vo.PowerCabinetVo;
import com.zhentao.service.SysPowerCabinetService;
import com.zhentao.mapper.SysPowerCabinetMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 86133
* @description 针对表【sys_power_cabinet】的数据库操作Service实现
* @createDate 2024-09-06 10:00:56
*/
@Service
public class SysPowerCabinetServiceImpl extends ServiceImpl<SysPowerCabinetMapper, SysPowerCabinet>
    implements SysPowerCabinetService{
    @Autowired
    private SysPowerCabinetMapper sysPowerCabinetMapper;
    //换电柜站点电柜管理（增删改查）
//查询
    @Override
    public PageInfo<PowerCabinetVo> getPowerCabinetList(PageDto pageDto) {
      PageHelper.startPage(pageDto.getPage(),pageDto.getSize());
      List<PowerCabinetVo> powerCabinetList = sysPowerCabinetMapper.getPowerCabinetList();
      PageInfo<PowerCabinetVo> powerCabinetVoPageInfo = new PageInfo<>(powerCabinetList);
        return powerCabinetVoPageInfo;
    }

    @Override
    public int getPowerCabinetsave(PowerCabinetVo powerCabinetVo) {
        boolean save = this.save(powerCabinetVo);
        return save ? 1 : 0;
    }

    @Override
    public int getPowerCabinetupdate(PowerCabinetVo powerCabinetVo) {
        boolean updateById = this.updateById(powerCabinetVo);
        return updateById ? 1 : 0;

    }

    @Override
    public int getPowerCabinetdelete(Integer id) {
        boolean b = this.removeById(id);
        return b ? 1 : 0;
    }
}




